home *** CD-ROM | disk | FTP | other *** search
/ Dr. Windows 3 / dr win3.zip / dr win3 / WINPROGS / UPC12BS1.ZIP / LIB / IMPORTNG.C < prev    next >
C/C++ Source or Header  |  1992-11-27  |  4KB  |  89 lines

  1. /*--------------------------------------------------------------------*/
  2. /*    i m p o r t n g . c                                             */
  3. /*                                                                    */
  4. /*    Create the fully-qualified path name for a news group           */
  5. /*    under UUPC/extended.                                            */
  6. /*                                                                    */
  7. /*    Copyright (c) 1992, by Andrew H. Derbyshire; all rights         */
  8. /*    reserved except as specified in UUPC/extended end-user          */
  9. /*    documentation.                                                  */
  10. /*--------------------------------------------------------------------*/
  11.  
  12. /*
  13.  *    $Id: IMPORTNG.C 1.2 1992/11/20 12:39:57 ahd Exp $
  14.  *
  15.  *    $Log: IMPORTNG.C $
  16.  * Revision 1.2  1992/11/20  12:39:57  ahd
  17.  * Drop boring message reporting mapping of name
  18.  *
  19.  */
  20.  
  21. /*--------------------------------------------------------------------*/
  22. /*                        System include files                        */
  23. /*--------------------------------------------------------------------*/
  24.  
  25. #include <stdio.h>
  26. #include <time.h>
  27. #include <string.h>
  28.  
  29. /*--------------------------------------------------------------------*/
  30. /*                    UUPC/extended include files                     */
  31. /*--------------------------------------------------------------------*/
  32.  
  33. #include "lib.h"
  34. #include "import.h"
  35. #include "hlib.h"
  36. #include "importng.h"
  37.  
  38. /*--------------------------------------------------------------------*/
  39. /*    I m p o r t N e w s G r o u p                                   */
  40. /*                                                                    */
  41. /*    Takes a news group and returns a directory path for it          */
  42. /*--------------------------------------------------------------------*/
  43.  
  44. char *ImportNewsGroup( char *local,
  45.                        const char *group,
  46.                        const long article )
  47. {
  48.    char fullpath[FILENAME_MAX];
  49.    char partial[FILENAME_MAX];
  50.    char *s;
  51.  
  52. /*--------------------------------------------------------------------*/
  53. /*    Combine the group with the name of the file of in the           */
  54. /*    newgroup, if needed.  Otherwise, copy the simple news group     */
  55. /*    name to our work buffer                                         */
  56. /*--------------------------------------------------------------------*/
  57.  
  58.    strcpy( partial, group);
  59.  
  60.    if ( article != 0 )
  61.       sprintf(partial + strlen( partial ),"/%ld", article );
  62.  
  63. /*--------------------------------------------------------------------*/
  64. /*    Transform all periods in the news group to slashes, which       */
  65. /*    allows for longer group names than allowed by the simple DOS    */
  66. /*    8 + 3 directory structure.                                      */
  67. /*--------------------------------------------------------------------*/
  68.  
  69.    while ((s = strchr(partial, '.')) != NULL)
  70.       *s = '/';
  71.  
  72.    while ((s = strchr(E_newsdir, '\\')) != NULL)
  73.       *s = '/';                                 /* Normalize slashes */
  74.  
  75. /*--------------------------------------------------------------------*/
  76. /*    Now combine the name with the root news directory; we do        */
  77. /*    this before importing the file name to insure we have a         */
  78. /*    path, which affects how ImportPath processes the file           */
  79. /*--------------------------------------------------------------------*/
  80.  
  81.    mkfilename( fullpath , E_newsdir, partial ); /* Build the name    */
  82.  
  83.    importpath( local, fullpath, NULL );        /* Truncate name and
  84.                                                    zap bad chars as
  85.                                                    needed            */
  86.    return local;
  87.  
  88. } /* ImportNewsGroup */
  89.